package com.lycx.businessmanager.controller.systemManager;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.lycx.businessmanager.controller.BaseController;
import com.lycx.businessmanager.model.Dept;
import com.lycx.businessmanager.service.IDeptService;

/**
 * 部门controller
 * 
 * @author lambert
 * 
 */

@Controller
@RequestMapping("/dept")
public class DeptController extends BaseController{
	@SuppressWarnings("unused")
	private static Logger log = Logger.getLogger(DeptController.class);
	private IDeptService deptService;

	public void setDeptService(IDeptService deptService) {
		this.deptService = deptService;
	}

	@RequestMapping(value = "/list")
	public ModelAndView list(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/system/dept/list");
		return mv;
	}
	
	@RequestMapping(value = "/getTreeList",method = RequestMethod.POST)
	@ResponseBody
	public List<Dept> getTreeList(Dept dept){
		List<Dept> deptList = null;
		deptList = deptService.selectForTree(dept);
        return deptList;
	}

	
	@RequestMapping(value = "/add",method = RequestMethod.POST)
	@ResponseBody
	public String add(Dept dept){
		String result = null;
		if(dept!=null){
	        result = deptService.add(dept);
		}
        return result;
	}
	
	@RequestMapping(value = "/del",method = RequestMethod.POST)
	@ResponseBody
	public String del(int ids[]){
		String result = null;
		result = deptService.del(ids);
		return result;
	}
	
	@RequestMapping(value = "/mod",method = RequestMethod.POST)
	@ResponseBody
	public String mod(Dept dept){
		String result = null;
		if(dept!=null){
			result = deptService.mod(dept);
		}
		return result;
	}
	
}
